//
//  EskLinePlot.h
//  Display the line chart that allow user select the plot symbol on the line
//  and slide left or right and the chart will display the value while the user
//  is moving the line along the chart.
//
//  Created by Ken Wong on 8/9/11.
//  Copyright 2011 Essence Work LLC. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CorePlot-CocoaTouch.h"

@protocol EskLinePlotDelegate;

@interface EskLinePlot : NSObject <CPTPlotSpaceDelegate, CPTPlotDataSource>
{
  @private
    CPTGraph *graph;
    CPTScatterPlot *belowPlot;
    CPTScatterPlot *abovePlot;
    CPTScatterPlot *balancePlot;
    CPTScatterPlot *rulerPlot;
    NSUInteger selectedCoordination;
    BOOL rangeChanged;
    NSUInteger numberOfPeriods;
    NSUInteger selectedNumberOfPeriods;
    NSUInteger numberOfDaysInCurrentMonth;
    NSString *selectedDateString;
    NSString *rulerDateString;
    NSUInteger rulerIndex;
    NSUInteger numberOfDaysInRange;
    CPTPlotSpaceAnnotation *symbolTextAnnotation;
    NSArray *selectedDailyKeys;
    NSUInteger timerCount;
    NSTimer *dataTimer;
    //NSMutableDictionary *copyOfDailyBalances;
    NSString *initStartDateString;
    NSDate *initStartDate;
    BOOL rulerEnabled;
    NSMutableArray *animationStartDailyKeys;
    NSMutableArray *animationUnitBal;
 
    

}

@property (nonatomic, retain) id<EskLinePlotDelegate> delegate;
@property (nonatomic, retain) NSArray *currentBalanceData;   //blue plot
@property (nonatomic, retain) NSArray *belowNinetyDaysDelinquentData;  //green plot
@property (nonatomic, retain) NSArray *aboveNinetyDaysDelinquentData;  //red plot
@property (nonatomic, retain) NSArray *years;
@property (nonatomic, retain) NSMutableDictionary *dailyBalances;
@property (nonatomic, retain) NSArray *dailyKeys;



// Render the chart on the hosting view from the view controller with the default theme.
- (void)renderInLayer:(CPTGraphHostingView *)layerHostingView withTheme:(CPTTheme *)theme;

// Change the select line plot color.
- (void)applyRulerPlotColor;
// Display annotation for each selected data point
//-(void)displayRulerAnnotation:(CPTScatterPlot *)plot recordIndex:(NSUInteger)index; 
-(void)displayRulerAnnotation;
-(void)removeRulerAnnotation;
-(void)linePlot:(EskLinePlot *)plot respondToRangeChangeFromDate:(NSString *)newFromDateString toDate:(NSString *)newToDateString;
-(void)prepareAnimationData;
@end


// Delegate to notify the view controller that the location of the line has changed.
@protocol EskLinePlotDelegate <NSObject> 
@optional
- (void)linePlot:(EskLinePlot *)plot indexLocation:(NSUInteger)index;
- (void)linePlot:(EskLinePlot *)plot selectedDate:(NSString *)selectedDateString;

@end
